// Author: wsfuyibing <682805@qq.com>
// Date: 2025-06-16

package responses

import (
	"gitee.com/go-libs/db-xorm/db"
	"server/app/http/models"
	"server/app/kind"
)

// TicketRecordResponse
// 场次购买记录.
type TicketRecordResponse struct {
	Id           int64
	OrderNo      kind.OrderNo
	ArcadeId     kind.ArcadeId
	TicketId     int64
	SessionId    int64
	UserId       kind.UserId
	Date         db.Date
	SeatId       int64
	State        kind.TicketRecord
	StateFlag    string
	StateText    string
	PayState     kind.PayState
	PayStateYes  bool
	PayStateText string

	ReturnMode      kind.ReturnMode
	ReturnModeText  string
	ReturnPrice     kind.Balance
	ReturnState     kind.ReturnState
	ReturnStateYes  bool
	ReturnStateText string
	ReturnCount     float64
	ReturnWeight    float64
	ReturnAmount    kind.Balance

	TimeStart  string
	TimeEnd    string
	Price      kind.Balance
	Discount   kind.Balance
	PayAmount  kind.Balance
	PaidAmount kind.Balance

	Arcade  *ArcadeResponse         `json:",omitempty"`
	Member  *ArcadeMemberResponse   `json:",omitempty"`
	Seat    *ArcadePondSeatResponse `json:",omitempty"`
	Session *TicketSessionResponse  `json:",omitempty"`
	User    *UserResponse           `json:",omitempty"`
}

// With
// 绑定数据.
func (o *TicketRecordResponse) With(m *models.TicketRecord) *TicketRecordResponse {
	o.Id = m.Id
	o.OrderNo = m.OrderNo
	o.ArcadeId = m.ArcadeId
	o.TicketId = m.TicketId
	o.SessionId = m.SessionId
	o.UserId = m.UserId
	o.Date = m.Date
	o.SeatId = m.SeatId
	o.State = m.State
	o.StateFlag = m.State.Flag()
	o.StateText = m.State.Text()
	o.PayState = m.PayState
	o.PayStateText = m.PayState.Text()
	o.PayStateYes = m.PayState.IsPaid()

	o.ReturnMode = m.ReturnMode
	o.ReturnModeText = m.ReturnMode.Text()
	o.ReturnPrice = m.ReturnPrice
	o.ReturnState = m.ReturnState
	o.ReturnStateYes = m.ReturnState.IsReturned()
	o.ReturnStateText = m.ReturnState.Text()
	o.ReturnCount = m.ReturnCount
	o.ReturnWeight = m.ReturnWeight
	o.ReturnAmount = m.ReturnAmount

	o.TimeStart = m.TimeStart
	o.TimeEnd = m.TimeEnd
	o.Price = m.Price
	o.Discount = m.Discount
	o.PayAmount = m.PayAmount
	o.PaidAmount = m.PaidAmount
	return o
}

// WithArcade
// 绑定钓场.
func (o *TicketRecordResponse) WithArcade(m *models.Arcades) *TicketRecordResponse {
	if m != nil {
		o.Arcade = (&ArcadeResponse{}).With(m)
	}
	return o
}

// WithMember
// 绑定会员.
func (o *TicketRecordResponse) WithMember(m *models.ArcadeMember) *TicketRecordResponse {
	if m != nil {
		o.Member = (&ArcadeMemberResponse{}).With(m)
	}
	return o
}

// WithSeat
// 绑定钓位.
func (o *TicketRecordResponse) WithSeat(m *models.ArcadePondSeat) *TicketRecordResponse {
	if m != nil {
		o.Seat = (&ArcadePondSeatResponse{}).With(m)
	}
	return o
}

// WithSession
// 绑定场次.
func (o *TicketRecordResponse) WithSession(m *models.TicketSession) *TicketRecordResponse {
	if m != nil {
		o.Session = (&TicketSessionResponse{}).With(m)
	}
	return o
}

// WithUser
// 绑定用户.
func (o *TicketRecordResponse) WithUser(m *models.Users) *TicketRecordResponse {
	if m != nil {
		o.User = (&UserResponse{}).With(m)
	}
	return o
}
